<%
layout("layout.html"){
%>
<div class="weui-cells__title">充值，不低于${min > 0 ? min / 100 : 0}元</div>
<div class="weui-cells weui-cells_form">
    <div class="weui-cell">
        <div class="weui-cell__hd">
            <label class="weui-label">金额</label>
        </div>
        <div class="weui-cell__bd">
            <input class="weui-input" type="number" placeholder="请输入充值金额" id="moneyInput" />
        </div>
    </div>
    <div class="weui-cells__tips">
        充值前先转账到对公账号，充值金额会稍后到账
    </div>
    <div class="weui-btn-area">
        <a href="javascript:" class="weui-btn weui-btn_primary" id="submitButton">确定</a>
    </div>
</div>
<script src="${ctxPath}/js/net.js"></script>
<script>
    $('#submitButton').click(function () {
        var record = {
            money: $('#moneyInput').val() * 100
        };
        if (record.money < ${min}) {
            alert('金额过小');
            return;
        }
        net()
            .url('${ctxPath}/api/rechargeRecords')
            .data(record)
            .success(function (response) {
                if (response.code == 0) {
                    showToast();
                    setTimeout(function () {
                        window.history.back();
                    }, 500);
                } else {
                    alert(response.message);
                }
            })
            .error(function () {
                alert('网络错误');
            })
            .post();
    });
</script>
<% } %>